<?php
/****
* 用户时间轴模块 获取用户最近动态(类似douban的在看\在听之类的)
****/
import('@.Model.Extend.TimelineUserModel');
class TimelineAction extends InitAction{
    protected function _initialize(){
        parent::_initialize();
    }
    public function index(){
	
        $this->display('user');
    }
    public function group(){
        $this->user();
    }
    public function user(){
        $uid= $_GET['uid'];
        $TLM= new TimelineUserModel();
        
        $map=array();
        if ($uid){
            $map['Timeline.uid']= $uid;
            $user= M('Account')->find($uid);
            $this->assign('user', $user);
        }
        if ($type= $_GET['type']){
            $map['Timeline.type']= $type;
        }
        $TLM->where($map);
        $tl= $TLM->select();
        $TIMELINE_TYPE= L('TIMELINE_TYPE');
        foreach($tl as &$t){
        
            if ($t['type']== TimelineModel::C('TYPE_WISH' )
                ||$t['type']==TimelineModel::C('TYPE_TAKE' )
                ||$t['type']==TimelineModel::C('TYPE_EVENT')){
                $t['aurl']= U("event/".$t['aid']);
            }else if($t['type']==TimelineModel::C('TYPE_TOPIC')){
                $t['aurl']= U("topic/".$t['aid']);
            }else if($t['type']==TimelineModel::C('TYPE_REPLY')){
                $t['aurl']= U("topic/".$t['xid']);
            }
            //$t['date']= date('Y-m-i', strtotime($t['stamp']));
            $t['date']= substr($t['stamp'],0, 10);
            $t['log']=$TIMELINE_TYPE[$t['type']];
        }
        $this->assign('timeline', $tl);
        $fm= new FriendModel();
        $this->assign('friends', $fm->getFriend() );
        $this->display('index');
    }
    /****
    * 获取热门社团
    ****/
    public function mockgetGroup(){
        $U= new AccountModel();
        return $U->order('`uid` DESC')->limit(12)->select();
    }
    public function type(){
        return $this->index();
    }
}
?>